package com.bruce.codeFactory.Thread;

import java.util.Optional;
import java.util.stream.IntStream;

/**
 * @author luotuan
 * @Description
 * @create 2019-02-18 22:50
 **/
public class JoinDemo {
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(() -> {
            IntStream.range(1, 100).forEach(i -> System.out.println(Thread.currentThread().getName() + "->" + i));
        });
        Thread t2 = new Thread(() -> {
            IntStream.range(1, 100).forEach(i -> System.out.println(Thread.currentThread().getName() + "->" + i));
        });
        t1.start();
        t2.start();
        t1.join();
        t2.join();
        System.out.println(Thread.currentThread().isInterrupted());
        Optional.of("All of tasks finished done.").ifPresent(System.out::println);
        IntStream.range(1, 100).forEach(i -> System.out.println(Thread.currentThread().getName() + "->" + i));
    }
}
